package com.neusoft.adminweb.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 与Web配置有关的，相当于web.xml
 * @Author: duan
 * @Date: Create in 11:29 2020/11/9
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
    /*
        WebMvcConfigurer：用于配置web相关的一些内容
            比如，静态资源和页面的访问，拦截等
     */

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        /*
            addViewControllers
                配置某些模板访问路径
            registry：注册器
         */
        registry.addViewController("toLogin").setViewName("whites/login");
        registry.addViewController("toWelcome").setViewName("pages/welcome");
//        registry.addRedirectViewController("toWelcome", "pages/welcome");不经过视图解析器
    }

//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(new LoginInterceptor());
//    }
}
